<?php
@session_start();
$errmsg=array();
$errflag=false;
include '../config/config.inc';

	function clean($str){
				if (get_magic_quotes_gpc()){
					$str=stripcslashes($str);
				}
				
return mysql_real_escape_string($str);	
			}
$email=clean($_POST['email']);
$name=clean($_POST['name']);
$area=clean($_POST['area']);
if (isset($_POST['submit'])){
	$co=mysql_connect(DB_HOST,DB_USER,DB_PASSWORD);
	if(!$co){
		echo mysql_error();
		}
		$sel=mysql_select_db(DB_DATABASE);
		if (!$sel){
			mysql_error();}

if ($email==""){
	$errmsg[]="this Felid can not be empty";
	$errflag=true;
}
if ($name==""){
$errmsg[]="fill this feild please ";
$errflag=true;	
}if($area==""){
	$errmsg[]=" fill this please";
	$errflag=true;
	
}
if($errflag){
	$_SESSION['ERROR_MSG']=$errmsg;
	session_write_close();
	header("location:../contact.php");
	exit();
}
$sql=mysql_query("INSERT INTO `contact` values(null,'$email','$name','$area')");
if($sql){
	header("location:../contact.php?status=success");
	}else {
		echo mysql_error();
	}
	
}else{
	echo "Send request is not press";
}
	
?>